<?php
/**
 * Created by PhpStorm.
 * User: 17274
 * Date: 2018/3/28
 * Time: 14:21
 */

namespace app\admin\controller;

use app\admin\model\MottoModel;
use think\Request;

class Motto extends Base
{
    protected $mottoModel;

    /*
     * 依赖注入Model
     * */
    public function __construct(MottoModel $mottoModel){
        parent::__construct();
        $this->mottoModel = $mottoModel;
    }

    /*
     * 列表
     * */
    public function motto_index(){
        $this->assign("data",$this->mottoModel->listAll());
        return $this->fetch('motto/index');
    }

    /*
    * 新增
    * */
    public function motto_add(){
        if(Request::instance()->isPost()){
            $validate=$this->mottoModel->validate_model('add');
            if ($validate['code']){
                return $this->mottoModel->add();
            }else{
                return $validate;
            }
        }
        return $this->fetch('motto/add');
    }

    /*
    * 修改 启用
    * */
    /*public function article_edit(){
        if(Request::instance()->isPost()){
            $validate=$this->articleModel->validate_model('edit');
            if ($validate['code']){
                return $this->articleModel->edit();
            }else{
                return $validate;
            }
        }
        $id=input('get.id/d');
        $this->assign("labels",$this->labelsModel->getByMaps($this->labelsMaps));
        $this->assign("data",$this->articleModel->getById($id));
        return $this->fetch('article/edit');
    }*/

    /*
    * 删除
    * */
    public function motto_del(){
        return $this->mottoModel->del();
    }


}